<template>
	<view class="all">
		
		  <scroll-view class="suoyougonghui" :scroll-y="true">
			  <view v-for="(item,index) in suoyougonghui" class="danggegonghui" data-index="{{index}}" @click="click">
				  <image class="gonghuitouxiang" src="@/static/logo.png"></image>
				  <view class="huiming">{{item.mingzi}}</view>
				  <view class="gonghuirenshu">{{item.renshu}}</view>
			  </view>
		  </scroll-view>
		  <view class="jianshu" v-if="show">
			  <image class="huizhangtouxiang" src="@/static/logo.png"></image>
			  <view class="huizhangming">{{gonghuixinxi.huizhang}}(会长)</view>
			  <view class="xuanyan">公会宣言</view>
			  <view class="gonghuijianshu">{{gonghuixinxi.jianshu}}</view>
			  <button class="jiaru" type="primary" @click="jiaru">申请加入</button>
		  </view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				suoyougonghui:[],
				gonghuixinxi:[],
				show:false,
				zhang:"",
				jieguo:""
			}
		},
		created(){
			this.zhang=getApp().globalData.zhang
			    uni.request({
			    	url:"http://124.221.104.5:8080/jbgn/suoyougonghui",
					success: (res) => {
						 this.suoyougonghui=res.data
					}
			    })
		},
		methods: {
			 click(event){
				 this.show=true
				 this.gonghuixinxi=this.suoyougonghui[event.currentTarget.dataset.index]
			 },
			async jiaru(){
				   uni.request({
				   	url:"http://124.221.104.5:8080/jbgn/jiarugonghui",
					data:{zhang:this.zhang,huizhang:this.gonghuixinxi.huizhang},
					success: (res) => {
						this.jieguo=res.data
					
					}
				   })
				   await new Promise((res)=>setTimeout(res,500))
				  
				  	 uni.showToast({
				  					icon:"none",
				  					title:this.jieguo,
				  					duration:1000
				  							  })
				 
			 }
		}
	}
</script>

<style>
 .all{  
	    position: absolute;
	    width: 601rpx;
		height: 378rpx;
	   margin-left:150rpx ;
	   top: 0%;
	
	 display: flex;
	 flex-direction: row;
	 align-items: center;
 }
 .suoyougonghui{
	 display:flex;
	 flex-direction: column;
	 align-items: center;
	 width: 350rpx;
	 height:378rpx ;
	 background-color: antiquewhite;
 }
 .danggegonghui{
	 height: 60rpx;
	 width: 100%;
	  border: 1rpx solid aqua;
	  display: flex;
	  flex-direction: row;
	  align-items: center;
	  
 }
 .gonghuitouxiang{
	 width: 50rpx;
	 height: 50rpx;
	 border-radius: 50%;
	 margin-left: 60rpx;
	
 }
 .huiming{
	 margin-left: 30rpx;
	 width: 30rpx;
 }
 
 .gonghuirenshu{
	 margin-left: 120rpx;
 }
 .jianshu{
	 height:378rpx ;
	 display: flex;
	 flex-direction: column;
	 align-items: center;
    margin-left: 50rpx;
 }
 .huizhangtouxiang{
	 margin-top: 20rpx;
	 width:100rpx ;
	 height: 100rpx;
	 border-radius: 100%;
	 
	
 }
 .huizhangming{
	 
	 margin-top: 10rpx;
	 height: 30rpx;
	 font-size: 25rpx;
 }
 .xuanyan{
	 margin-top: 20rpx;
	 height: 30rpx;
	  font-size: 20rpx;
 }
 .gonghuijianshu{
	 margin-top: 5rpx;
	  font-size: 19rpx;
	  width:151rpx ;
	  height: 90rpx;
	  text-align: center;
	word-break: break-all;
 }
 .jiaru{
	    height: 30rpx;
	   margin-top: 20rpx;
	   line-height: 30rpx;
 }
 
</style>
